# -*- coding:utf-8 -*-
from PySide.QtCore import *
from PySide.QtGui import *
import sys

QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8"))

class StockDialog(QDialog):
    def __init__(self,parent=None):
        super(StockDialog,self).__init__(parent)
        self.setWindowTitle(self.tr("堆栈窗口"))

        listWidget=QListWidget()
        listWidget.insertItem(0,self.tr("窗口1"))
        listWidget.insertItem(1,self.tr("窗口2"))
        listWidget.insertItem(2,self.tr("窗口3"))
        listWidget.insertItem(3,self.tr("窗口4"))

        label1=QLabel(self.tr("这是窗口1"))
        label2 = QLabel(self.tr("这是窗口2"))
        label3 = QLabel(self.tr("这是窗口3"))
        label4 = QLabel(self.tr("这是窗口4"))

        stack=QStackedWidget()
        stack.addWidget(label1)
        stack.addWidget(label2)
        stack.addWidget(label3)
        stack.addWidget(label4)

        #添加箱子布局
        mainLayout=QHBoxLayout(self)
        mainLayout.setContentsMargins(5,5,5,5)
        mainLayout.setSpacing(5)
        mainLayout.addWidget(listWidget)
        #控件剧中
        mainLayout.addWidget(stack,0,Qt.AlignCenter)
        mainLayout.setStretchFactor(listWidget,1)
        mainLayout.setStretchFactor(stack,3)

        self.connect(listWidget,SIGNAL("currentRowChanged(int)"),stack,SLOT("setCurrentIndex(int)"))




if __name__ =="__main__":
    app=QApplication(sys.argv)
    stockDialog=StockDialog()
    stockDialog.show()
    sys.exit(app.exec_())